<template>
  <div>
    <a-modal
      :title="this.title"
      :visible="this.visible"
      :width="660"
      @cancel="cancel"
      @ok="ok"
    >
      <a-tabs type="card"  @change="callback" >
        <a-tab-pane key="1" tab="评估任务" >
          <a-form
            :form="form1"
            v-bind="formItemLayout"
          >
            <a-form-item label="任务名称">
              <a-input :value="this.reocrd.name" readOnly
              />
            </a-form-item>
            <a-form-item label="任务详情">
              <a-input :value="this.reocrd.taskdes" readOnly
              />
            </a-form-item>
            <a-form-item label="任务分类">
              <a-input :value="this.reocrd.taskClassify" readOnly
              />
            </a-form-item>
            <a-form-item label="任务开始时间">
              <a-input :value="this.reocrd.starttime" readOnly
              />
            </a-form-item>
            <a-form-item label="任务结束时间">
              <a-input :value="this.reocrd.endtime" readOnly
              />
            </a-form-item>
            <a-form-item label="创建人">
              <a-input :value="this.reocrd.creator" readOnly
              />
            </a-form-item>
            <a-form-item label="创建时间">
              <a-input :value="this.reocrd.creattime" readOnly
              />
            </a-form-item>
            <a-form-item label="审批人">
              <a-input :value="this.reocrd.approver" readOnly
              />
            </a-form-item>
            <a-form-item label="审批时间">
              <a-input :value="this.reocrd.approvtime" readOnly
              />
            </a-form-item>
            <a-form-item label="状态">
              <a-input :value="this.reocrd.status" readOnly
              />
            </a-form-item>
            <!-- 			  <a-form-item label="生产任务单">
                        <a-upload
                          name="file"
                          :action="fileAction"
                          @change="handleUploadChange"
                           :showUploadList="false"
                           :data="uploadParam"
                          v-decorator="this.validator.upload"
                           >
                          <a-button> <a-icon type="upload" /> 选择文件 </a-button>
                        </a-upload>
                      </a-form-item> -->
            <!--            <a-form-item label="范围">-->
            <!--              <a-tree-select-->
            <!--                show-search-->
            <!--                style="width: 100%"-->
            <!--                :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"-->
            <!--                allow-clear-->
            <!--                tree-checkable-->
            <!--                tree-default-expand-all-->
            <!--                v-decorator="this.validator.upload"-->
            <!--                @change="onChange"-->
            <!--                :disabled="this.see"-->
            <!--                :show-checked-strategy="SHOW_PARENT"-->
            <!--              >-->
            <!--              </a-tree-select>-->
            <!--            </a-form-item>-->
            <!--            <a-form-item label="流程编排">-->
            <!--              <a-button type="primary" @click="flowArrange">-->
            <!--                流程编排-->
            <!--              </a-button>-->
            <!--            </a-form-item>-->
            <!--            <a-form-item label="任务时间">-->
            <!--              <a-range-picker-->
            <!--                v-decorator="this.validator.fronttime"-->
            <!--              />-->
            <!--            </a-form-item>-->

          </a-form>
        </a-tab-pane>
      </a-tabs>
    </a-modal>
    <modal
      ref="flowModalForm"
      :flowTitle="modalFlowTitle"
      :flowVisible="modalFlowVisible"
      @cancel="handleCancel"
      @ok="handleOk"
    >
    </modal>
  </div>
</template>

<script>
import aModal from "@/common/modal"
import modal from "./flowModal"
import {
  UPLOADESTIMATE,
  UPLOADPRODUCT,
  GETFLOWDATA
} from '@/../static/js/apis.js'
import {
  productTaskForm
} from "@/../static/js/formValidators.js"
import global from "@/../static/global.vue"
import {TreeSelect} from 'ant-design-vue';
const SHOW_PARENT=TreeSelect.SHOW_PARENT
export default{
  inject:['reload'],                                 //注入App里的reload方法
  name: "taskModal",
  props: ['title', 'visible','reocrd'],
  components: {
    aModal,
    modal
  },
  data () {
    return {
      formItemLayout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 14 },
      },
      taskType:'数据',
      fileAction: UPLOADPRODUCT.url,   //导入文件提交路径
      estimateFileAction:UPLOADESTIMATE.url,
      service: [],
      userid:'',
      uploadParam:{},
      modalFlowTitle:'流程编排',
      modalFlowVisible:false,
      area:[],
      see:false,
      SHOW_PARENT
    }
  },
  beforeCreate() {
    this.form1 = this.$form.createForm(this, { name: 'productTaskForm' });
  },
  computed: {
    headers () {
      return {
        "token" : localStorage.getItem("token")
      }
    }
  },
  methods: {
    handleOk (e) {
      this.modalFlowVisible = false;

    },
    handleCancel(e) {
      self.see=false;
      this.modalFlowVisible = false
    },
    flowArrange(){
      let self=this
      if(self.area.length==0){
        self.$message.error("请选择范围");
      }else{
        localStorage.setItem("spinning", true)
        console.log(self.area);
        GETFLOWDATA(self.area,function(res){
          // console.log(res);
          localStorage.setItem("connlist", JSON.stringify(res.obj.connlist));
          localStorage.setItem("list", JSON.stringify(res.obj.list1));
          self.modalFlowVisible = true
        })

      }
      self.see=true;
    },
    callback(key) {
      this.tabType = key;
    },
    onChange(value, label, extra) {
      // console.log(extra.triggerValue);
      // console.log(value);

      /*if(value.length>1){
        this.area=[extra.triggerValue];
      }else{
        this.area=value;
      }*/

      this.area=value;
      console.log(this.area);

    },
    getStaticData () {

    },
    handleUploadChange(info) {
      if (info.file.status === 'done') {
        this.$message.success(`${info.file.name} 上传成功`);
      } else if (info.file.status === 'error') {
        this.$message.error(`${info.file.name} 上传失败`);
      }
    },
    ok(e) {
      let self=this;
      self.reload();


    },
    /*关闭modal*/
    cancel(e) {
      this.form1.resetFields();
      this.see = false;
      this.$emit("cancel", e);
      // self.see=false;
    },
  },
  created() {
    this.getStaticData()
    var jsonData={}
    jsonData=JSON.stringify(jsonData)
    localStorage.setItem("flowJson", jsonData)
  },

}
</script>

<style scoped>

</style>
